```html
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>岛屿数量 - 算法可视化</title>
    <link href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <link href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', 'Noto Serif SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            background-color: #f8fafc;
            color: #1e293b;
        }
        .hero-gradient {
            background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
        }
        .code-block {
            background-color: #1e293b;
            border-left: 4px solid #3b82f6;
        }
        .algorithm-card:hover {
            transform: translateY(-5px);
            box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
        }
        .grid-cell {
            transition: all 0.3s ease;
        }
        .grid-cell:hover {
            transform: scale(1.1);
            z-index: 10;
        }
        .grid-visualization {
            box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
        }
    </style>
</head>
<body>
    <!-- Hero Section -->
    <section class="hero-gradient text-white py-20 px-6">
        <div class="container mx-auto max-w-6xl">
            <div class="flex flex-col md:flex-row items-center">
                <div class="md:w-1/2 mb-10 md:mb-0">
                    <h1 class="text-4xl md:text-5xl font-bold mb-4">岛屿数量算法</h1>
                    <p class="text-xl opacity-90 mb-6">探索深度优先搜索(DFS)在图遍历中的应用</p>
                    <div class="flex space-x-4">
                        <div class="bg-white bg-opacity-20 p-3 rounded-lg flex items-center">
                            <i class="fas fa-code mr-2"></i>
                            <span>算法可视化</span>
                        </div>
                        <div class="bg-white bg-opacity-20 p-3 rounded-lg flex items-center">
                            <i class="fas fa-project-diagram mr-2"></i>
                            <span>网格分析</span>
                        </div>
                    </div>
                </div>
                <div class="md:w-1/2 flex justify-center">
                    <div class="grid-visualization bg-white bg-opacity-10 p-4 rounded-lg">
                        <div class="grid grid-cols-5 gap-1">
                            <div class="grid-cell w-10 h-10 bg-emerald-400 rounded flex items-center justify-center font-bold">1</div>
                            <div class="grid-cell w-10 h-10 bg-emerald-400 rounded flex items-center justify-center font-bold">1</div>
                            <div class="grid-cell w-10 h-10 bg-emerald-400 rounded flex items-center justify-center font-bold">1</div>
                            <div class="grid-cell w-10 h-10 bg-emerald-400 rounded flex items-center justify-center font-bold">1</div>
                            <div class="grid-cell w-10 h-10 bg-blue-400 rounded flex items-center justify-center font-bold">0</div>
                            
                            <div class="grid-cell w-10 h-10 bg-emerald-400 rounded flex items-center justify-center font-bold">1</div>
                            <div class="grid-cell w-10 h-10 bg-emerald-400 rounded flex items-center justify-center font-bold">1</div>
                            <div class="grid-cell w-10 h-10 bg-blue-400 rounded flex items-center justify-center font-bold">0</div>
                            <div class="grid-cell w-10 h-10 bg-emerald-400 rounded flex items-center justify-center font-bold">1</div>
                            <div class="grid-cell w-10 h-10 bg-blue-400 rounded flex items-center justify-center font-bold">0</div>
                            
                            <div class="grid-cell w-10 h-10 bg-emerald-400 rounded flex items-center justify-center font-bold">1</div>
                            <div class="grid-cell w-10 h-10 bg-emerald-400 rounded flex items-center justify-center font-bold">1</div>
                            <div class="grid-cell w-10 h-10 bg-blue-400 rounded flex items-center justify-center font-bold">0</div>
                            <div class="grid-cell w-10 h-10 bg-blue-400 rounded flex items-center justify-center font-bold">0</div>
                            <div class="grid-cell w-10 h-10 bg-blue-400 rounded flex items-center justify-center font-bold">0</div>
                            
                            <div class="grid-cell w-10 h-10 bg-blue-400 rounded flex items-center justify-center font-bold">0</div>
                            <div class="grid-cell w-10 h-10 bg-blue-400 rounded flex items-center justify-center font-bold">0</div>
                            <div class="grid-cell w-10 h-10 bg-blue-400 rounded flex items-center justify-center font-bold">0</div>
                            <div class="grid-cell w-10 h-10 bg-blue-400 rounded flex items-center justify-center font-bold">0</div>
                            <div class="grid-cell w-10 h-10 bg-blue-400 rounded flex items-center justify-center font-bold">0</div>
                        </div>
                        <div class="mt-4 text-center">
                            <p class="text-white font-medium">示例网格：1个岛屿</p>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <!-- Problem Description -->
    <section class="py-16 px-6">
        <div class="container mx-auto max-w-6xl">
            <div class="bg-white rounded-xl shadow-lg p-8">
                <h2 class="text-3xl font-bold mb-6 text-slate-800 flex items-center">
                    <i class="fas fa-question-circle text-blue-500 mr-3"></i>
                    题目描述
                </h2>
                <div class="prose max-w-none text-slate-700">
                    <p>给定一个由 <code class="bg-slate-100 px-2 py-1 rounded">'1'</code>（陆地）和 <code class="bg-slate-100 px-2 py-1 rounded">'0'</code>（水）组成的二维网格地图，计算岛屿的数量。</p>
                    <p class="my-4">岛屿总是被水包围，并且每座岛屿只能由水平方向和/或竖直方向上相邻的陆地连接形成。网格的四个边均被水包围。</p>
                    <div class="bg-slate-50 p-4 rounded-lg border-l-4 border-blue-500">
                        <p class="font-medium text-slate-800">示例输入：</p>
                        <p class="mt-2"><code>[["1","1","1","1","0"], ["1","1","0","1","0"], ["1","1","0","0","0"], ["0","0","0","0","0"]]</code></p>
                        <p class="mt-2 font-medium text-slate-800">输出：<span class="text-blue-600">1</span>（表示有1个岛屿）</p>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <!-- Algorithm Solutions -->
    <section class="py-16 px-6 bg-slate-50">
        <div class="container mx-auto max-w-6xl">
            <h2 class="text-3xl font-bold mb-10 text-slate-800 text-center">
                <i class="fas fa-lightbulb text-yellow-500 mr-3"></i>
                解题方法
            </h2>
            
            <div class="grid md:grid-cols-3 gap-8">
                <!-- DFS Card -->
                <div class="algorithm-card bg-white rounded-xl shadow-lg overflow-hidden transition-all duration-300">
                    <div class="bg-blue-600 py-4 px-6 text-white">
                        <h3 class="text-xl font-bold flex items-center">
                            <i class="fas fa-project-diagram mr-3"></i>
                            DFS 深度优先搜索
                        </h3>
                    </div>
                    <div class="p-6">
                        <p class="text-slate-700 mb-4">遍历网格，遇到陆地 ("1") 时，使用 DFS 将相连的陆地标记为已访问，计数岛屿数量。</p>
                        <div class="mb-4">
                            <p class="font-medium text-slate-800">时间复杂度：</p>
                            <p class="text-slate-600">O(m×n)</p>
                        </div>
                        <div class="mb-4">
                            <p class="font-medium text-slate-800">空间复杂度：</p>
                            <p class="text-slate-600">O(m×n)（递归栈或标记数组）</p>
                        </div>
                    </div>
                </div>
                
                <!-- BFS Card -->
                <div class="algorithm-card bg-white rounded-xl shadow-lg overflow-hidden transition-all duration-300">
                    <div class="bg-emerald-600 py-4 px-6 text-white">
                        <h3 class="text-xl font-bold flex items-center">
                            <i class="fas fa-expand mr-3"></i>
                            BFS 广度优先搜索
                        </h3>
                    </div>
                    <div class="p-6">
                        <p class="text-slate-700 mb-4">类似 DFS，使用队列代替递归实现，从起点向外逐层扩展标记相连陆地。</p>
                        <div class="mb-4">
                            <p class="font-medium text-slate-800">时间复杂度：</p>
                            <p class="text-slate-600">O(m×n)</p>
                        </div>
                        <div class="mb-4">
                            <p class="font-medium text-slate-800">空间复杂度：</p>
                            <p class="text-slate-600">O(min(m,n))</p>
                        </div>
                    </div>
                </div>
                
                <!-- Union-Find Card -->
                <div class="algorithm-card bg-white rounded-xl shadow-lg overflow-hidden transition-all duration-300">
                    <div class="bg-purple-600 py-4 px-6 text-white">
                        <h3 class="text-xl font-bold flex items-center">
                            <i class="fas fa-link mr-3"></i>
                            并查集
                        </h3>
                    </div>
                    <div class="p-6">
                        <p class="text-slate-700 mb-4">将相邻陆地合并为一个集合，最终统计集合数量即为岛屿数量。</p>
                        <div class="mb-4">
                            <p class="font-medium text-slate-800">时间复杂度：</p>
                            <p class="text-slate-600">O(m×n×α(mn))</p>
                        </div>
                        <div class="mb-4">
                            <p class="font-medium text-slate-800">空间复杂度：</p>
                            <p class="text-slate-600">O(m×n)</p>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <!-- Code Implementation -->
    <section class="py-16 px-6">
        <div class="container mx-auto max-w-6xl">
            <div class="bg-white rounded-xl shadow-lg overflow-hidden">
                <div class="bg-slate-800 py-4 px-6 text-white flex justify-between items-center">
                    <h2 class="text-xl font-bold flex items-center">
                        <i class="fas fa-code mr-3"></i>
                        DFS 实现代码 (Java)
                    </h2>
                    <div class="flex space-x-2">
                        <span class="bg-blue-500 text-xs px-2 py-1 rounded">边界检查</span>
                        <span class="bg-emerald-500 text-xs px-2 py-1 rounded">DFS遍历</span>
                        <span class="bg-purple-500 text-xs px-2 py-1 rounded">递归标记</span>
                    </div>
                </div>
                <div class="p-6">
                    <div class="code-block rounded-lg overflow-hidden">
                        <pre class="text-slate-100 text-sm md:text-base overflow-x-auto p-6">
<code><span class="text-blue-300">public int</span> <span class="text-emerald-300">numIslands</span>(<span class="text-blue-300">char</span>[][] grid) {
    <span class="text-gray-400">// 边界检查</span>
    <span class="text-blue-400">if</span> (grid == <span class="text-blue-400">null</span> || grid.length == <span class="text-yellow-300">0</span> || grid[<span class="text-yellow-300">0</span>].length == <span class="text-yellow-300">0</span>) {
        <span class="text-blue-400">return</span> <span class="text-yellow-300">0</span>;
    }
    
    <span class="text-gray-400">// 获取网格的行数和列数</span>
    <span class="text-blue-300">int</span> rows = grid.length;
    <span class="text-blue-300">int</span> cols = grid[<span class="text-yellow-300">0</span>].length;
    
    <span class="text-gray-400">// 岛屿计数</span>
    <span class="text-blue-300">int</span> count = <span class="text-yellow-300">0</span>;
    
    <span class="text-gray-400">// 遍历整个网格</span>
    <span class="text-blue-400">for</span> (<span class="text-blue-300">int</span> i = <span class="text-yellow-300">0</span>; i < rows; i++) {
        <span class="text-blue-400">for</span> (<span class="text-blue-300">int</span> j = <span class="text-yellow-300">0</span>; j < cols; j++) {
            <span class="text-gray-400">// 如果当前单元格是陆地（'1'）</span>
            <span class="text-blue-400">if</span> (grid[i][j] == <span class="text-yellow-300">'1'</span>) {
                <span class="text-gray-400">// 使用DFS将与当前陆地相连的所有陆地标记为已访问</span>
                <span class="text-emerald-300">dfs</span>(grid, i, j);
                <span class="text-gray-400">// 找到一个新的岛屿，计数加1</span>
                count++;
            }
        }
    }
    
    <span class="text-gray-400">// 返回岛屿总数</span>
    <span class="text-blue-400">return</span> count;
}

<span class="text-gray-400">/**
 * 深度优先搜索，将与当前陆地相连的所有陆地标记为已访问（将'1'改为'0'）
 * @param grid 网格
 * @param i 当前行索引
 * @param j 当前列索引
 */</span>
<span class="text-blue-300">private void</span> <span class="text-emerald-300">dfs</span>(<span class="text-blue-300">char</span>[][] grid, <span class="text-blue-300">int</span> i, <span class="text-blue-300">int</span> j) {
    <span class="text-gray-400">// 边界检查：如果索引越界或当前单元格不是陆地，则返回</span>
    <span class="text-blue-400">if</span> (i < <span class="text-yellow-300">0</span> || i >= grid.length || j < <span class="text-yellow-300">0</span> || j >= grid[<span class="text-yellow-300">0</span>].length || grid[i][j] != <span class="text-yellow-300">'1'</span>) {
        <span class="text-blue-400">return</span>;
    }
    
    <span class="text-gray-400">// 将当前陆地标记为已访问（改为'0'）</span>
    grid[i][j] = <span class="text-yellow-300">'0'</span>;
    
    <span class="text-gray-400">// 递归访问上、下、左、右四个相邻单元格</span>
    <span class="text-emerald-300">dfs</span>(grid, i + <span class="text-yellow-300">1</span>, j); <span class="text-gray-400">// 下</span>
    <span class="text-emerald-300">dfs</span>(grid, i - <span class="text-yellow-300">1</span>, j); <span class="text-gray-400">// 上</span>
    <span class="text-emerald-300">dfs</span>(grid, i, j + <span class="text-yellow-300">1</span>); <span class="text-gray-400">// 右</span>
    <span class="text-emerald-300">dfs</span>(grid, i, j - <span class="text-yellow-300">1</span>); <span class="text-gray-400">// 左</span>
}</code>
                        </pre>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <!-- Visualization -->
    <section class="py-16 px-6 bg-slate-50">
        <div class="container mx-auto max-w-6xl">
            <h2 class="text-3xl font-bold mb-10 text-slate-800 text-center">
                <i class="fas fa-chart-network text-purple-500 mr-3"></i>
                算法流程可视化
            </h2>
            
            <div class="bg-white rounded-xl shadow-lg p-8">
                <div class="flex flex-col md:flex-row">
                    <div class="md:w-1/2 mb-6 md:mb-0 md:pr-6">
                        <h3 class="text-xl font-bold mb-4 text-slate-800">DFS 遍历过程</h3>
                        <p class="text-slate-700 mb-6">深度优先搜索(DFS)通过递归方式探索所有相连的陆地单元格，将它们标记为已访问，从而避免重复计数。</p>
                        
                        <div class="space-y-4">
                            <div class="flex items-start">
                                <div class="bg-blue-100 text-blue-800 rounded-full w-8 h-8 flex items-center justify-center flex-shrink-0 mr-3">
                                    <span class="font-bold">1</span>
                                </div>
                                <p class="text-slate-700">从网格左上角开始遍历，寻找未访问的陆地('1')</p>
                            </div>
                            <div class="flex items-start">
                                <div class="bg-blue-100 text-blue-800 rounded-full w-8 h-8 flex items-center justify-center flex-shrink-0 mr-3">
                                    <span class="font-bold">2</span>
                                </div>
                                <p class="text-slate-700">发现陆地后，递归访问其上下左右相邻单元格</p>
                            </div>
                            <div class="flex items-start">
                                <div class="bg-blue-100 text-blue-800 rounded-full w-8 h-8 flex items-center justify-center flex-shrink-0 mr-3">
                                    <span class="font-bold">3</span>
                                </div>
                                <p class="text-slate-700">将已访问的陆地标记为'0'，避免重复计数</p>
                            </div>
                            <div class="flex items-start">
                                <div class="bg-blue-100 text-blue-800 rounded-full w-8 h-8 flex items-center justify-center flex-shrink-0 mr-3">
                                    <span class="font-bold">4</span>
                                </div>
                                <p class="text-slate-700">完成一个岛屿的标记后，岛屿计数加1</p>
                            </div>
                            <div class="flex items-start">
                                <div class="bg-blue-100 text-blue-800 rounded-full w-8 h-8 flex items-center justify-center flex-shrink-0 mr-3">
                                    <span class="font-bold">5</span>
                                </div>
                                <p class="text-slate-700">继续遍历网格，直到所有单元格处理完毕</p>
                            </div>
                        </div>
                    </div>
                    
                    <div class="md:w-1/2">
                        <h3 class="text-xl font-bold mb-4 text-slate-800">概念关系图</h3>
                        <div class="mermaid">
                            graph TD
                                A["岛屿数量问题"] --> B["DFS/BFS遍历"]
                                A --> C["并查集"]
                                B --> D["递归/迭代实现"]
                                B --> E["标记已访问"]
                                C --> F["路径压缩"]
                                C --> G["按秩合并"]
                                D --> H["时间复杂度: O(mn)"]
                                E --> H
                                F --> I["优化查找效率"]
                                G --> I
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <script>
        mermaid.initialize({
            startOnLoad: true,
            theme: 'default',
            flowchart: {
                useMaxWidth: true,
                htmlLabels: true,
                curve: 'basis'
            }
        });
    </script>
</body>
</html>
```